//
//  SISSCoopDrafsCell.m
//  SISSAPP
//
//  Created by 优房网 on 2017/7/24.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSCoopDrafsCell.h"


@interface SISSCoopDrafsCell ()

/// 发布方Label
@property (weak, nonatomic) UILabel *publisherLabel;
@property (weak, nonatomic) UILabel *publisherTitleLabel;
/// 合作方Label
@property (weak, nonatomic) UILabel *partnerLabel;
@property (weak, nonatomic) UILabel *partnerTitleLabel;
/// 保存时间Label
@property (weak, nonatomic) UILabel *timeLabel;

/// 底部线条view
@property (weak, nonatomic) UIView *lineView;

@end
@implementation SISSCoopDrafsCell

- (void)setCoopAgreementDraftModel:(SISSCoopAgreementDraftModel *)coopAgreementDraftModel {
    _coopAgreementDraftModel = coopAgreementDraftModel;
    
    self.publisherLabel.text = coopAgreementDraftModel.name;
    self.partnerLabel.text = coopAgreementDraftModel.requestName;
    self.timeLabel.text = [coopAgreementDraftModel.insertTime substringToIndex:16];
}

- (void)setFirstTitle:(NSString *)firstTitle {
    _firstTitle = firstTitle;
    self.publisherTitleLabel.text = firstTitle;
}

- (void)setSecondTitle:(NSString *)secondTitle {
    _secondTitle = secondTitle;
    self.partnerTitleLabel.text = secondTitle;
}

- (void)setFirstName:(NSString *)firstName {
    _firstName = firstName;
    self.publisherLabel.text = firstName;
}

- (void)setSecondName:(NSString *)secondName {
    _secondName = secondName;
    self.partnerLabel.text = secondName;
}

- (void)setTimeStr:(NSString *)timeStr {
    _timeStr = timeStr;
    self.timeLabel.text = timeStr;
}

#pragma mark - UI
- (void)initUI {
    [super initUI];
    
    UILabel *publisherTitleLabel = [[UILabel alloc] init];
    publisherTitleLabel.text = @"发布方：";
    publisherTitleLabel.textColor = COLOR(0x8998A5);
    publisherTitleLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:publisherTitleLabel];
    self.publisherTitleLabel = publisherTitleLabel;
    
    UILabel *publisherLabel = [[UILabel alloc] init];
    publisherLabel.text = @"王中介";
    publisherLabel.textColor = MAIN_TEXT_COLOR;
    publisherLabel.font = [UIFont boldSystemFontOfSize:15];
    publisherLabel.numberOfLines = 0;
    [self.contentView addSubview:publisherLabel];
    self.publisherLabel = publisherLabel;
    
    UILabel *partnerTitleLabel = [[UILabel alloc] init];
    partnerTitleLabel.text = @"合作方：";
    partnerTitleLabel.textColor = COLOR(0x8998A5);
    partnerTitleLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:partnerTitleLabel];
    self.partnerTitleLabel = partnerTitleLabel;
    
    UILabel *partnerLabel = [[UILabel alloc] init];
    partnerLabel.text = @"刘中介";
    partnerLabel.textColor = MAIN_TEXT_COLOR;
    partnerLabel.font = [UIFont boldSystemFontOfSize:15];
    [self.contentView addSubview:partnerLabel];
    self.partnerLabel = partnerLabel;
    
    UILabel *timeLabel = [[UILabel alloc] init];
    timeLabel.text = @"2017-7-24 09:37";
    timeLabel.textColor = COLOR(0x8998A5);
    timeLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:timeLabel];
    self.timeLabel = timeLabel;
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:lineView];
    self.lineView = lineView;
}

#pragma mark - 约束
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    [self.publisherTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView).offset(margin);
        make.top.equalTo(weakSelf.contentView).offset(margin);
    }];
    [self.publisherLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.publisherTitleLabel.mas_right);
        make.top.equalTo(weakSelf.publisherTitleLabel);
    }];
    
    [self.partnerTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.publisherTitleLabel);
        make.top.equalTo(weakSelf.publisherLabel.mas_bottom).offset(2 * margin);
    }];
    [self.partnerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.partnerTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.partnerTitleLabel);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.partnerTitleLabel);
        make.top.equalTo(weakSelf.partnerTitleLabel.mas_bottom).offset(2 * margin);
        make.bottom.equalTo(weakSelf.lineView).offset(- margin);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(weakSelf.contentView);
        make.height.mas_equalTo(1);
    }];

}

@end
